<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var obj = {
      username:"admin1",
      password:123321
    }
    // 1.创建一个请求实例
    var xhr = new XMLHttpRequest();
    // 2.打开一个连接
    xhr.open('post','http://121.199.0.35:8888/user/login');
    // 3.发送请求
    // 3.1 设置请求头格式为json格式
    xhr.setRequestHeader('Content-Type','application/json');
    xhr.send(JSON.stringify(obj));
    // 4.监听响应
    xhr.onreadystatechange = function(){
      if(xhr.readyState ===4 && xhr.status===200){
        console.log(JSON.parse(xhr.response))
      }
    }
  </script>
</body>
</html>